package com.frank.loadinglibrary.base.basecomponent;

import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.render.Canvas;
import ohos.app.Context;

public class BaseComponent extends Component implements Component.DrawTask, Component.BindStateChangedListener {

    //是否自动启动动画
    private boolean auto = true;

    public BaseComponent(Context context) {
        this(context, null);
    }

    public BaseComponent(Context context, AttrSet attrSet) {
        this(context, attrSet, "");
    }

    public BaseComponent(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
        init(context);
    }

    public BaseComponent(Context context, AttrSet attrSet, int resId) {
        super(context, attrSet, resId);
        init(context);
    }

    /**
     * 初始化
     *
     * @param ctx
     */
    private void init(Context ctx) {
        setBindStateChangedListener(this);
    }

    @Override
    public void onDraw(Component component, Canvas canvas) {
        //TODO 绘制内容
    }


    @Override
    public void onComponentBoundToWindow(Component component) {
        //TODO 绑定到窗口
    }

    @Override
    public void onComponentUnboundFromWindow(Component component) {
        //从窗口移除
    }

    public Component setAutoAnimation(boolean auto) {
        this.auto = auto;
        return this;
    }

    public void startAnimation() {
        //TODO 开始动画
    }

    public void stopAnimation() {
        //TODO 停止动画
    }

    public void pauseAnimation() {
        //TODO 暂停动画
    }

    public void resumeAnimation() {
        //TODO 继续播放动画
    }

    public void resetAnimation() {
        //TODO 重置动画到初始状态 并播放
    }

    public void releaseSource() {
        //TODO 释放资源
    }
}
